package com.zjj.algorithm.learning.niuke;

import java.util.Scanner;

/**
 * @author zjj_admin
 * @date 2023/2/9 22:02
 */
public class Test55 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        int res = 0;
        for (int i = 1; i <= num; i++) {
            if (isSeven(i + "")) {
                res++;
            }
        }
        System.out.println(num - res);
    }


    public static boolean isSeven(String num) {
        int anInt = Integer.parseInt(num);
        if (anInt % 7 == 0) {
            return false;
        }
        for (int i = 0; i < num.length(); i++) {
            if (num.charAt(i) == '7') {
                return false;
            }
        }
        return true;
    }
}
